const dbMod = require('../db/dbMod');

function register (userAccount, password, userTime, callback) {
  let sql1 = 'INSERT INTO account (userAccount,password,userPower,userStatus) VALUES (?,?,0,1)'
  dbMod.query(sql1, [userAccount, password], function (result) {
    sql2 = "INSERT INTO user (userID, userAccount, userName, userGender, userAge, userTime, userProfile) VALUES (?, ?, ?, 'others', 0, ?, '这个人很懒，什么都没有留下')"
    dbMod.query(sql2, [result.insertId, userAccount, 'uacd_' + userAccount, userTime], (result) => {
      callback(result)
    })
  })
}

exports.register = register